# 学员信息在线管理
import todo


a = todo.Todo()


while True:
	# 输出初始界面
	print("="*12,"学员管理系统","="*14)
	print("{0:1} {1:13} {2:15}".format(" ","1. 查看学员信息","2. 添加学员信息"))
	print("{0:1} {1:13} {2:15}".format(" ","3. 删除学员信息","4. 退出系统"))
	print("="*40)
	key = input("请输入对应的选择：")
	# 根据键盘值，判断并执行对应的操作
	if key == "1":
		print("="*12,"学员信息浏览","="*14)
		sql1 = 'select * from stu'
		stulist = a.FindAll(sql1)
		for i in stulist:
			print(i)
		input("按回车键继续：")

	elif key == "2":
		print("="*12,"学员信息添加","="*14)
		name = input("请输入要添加的姓名：")
		age = int(input("请输入要添加的年龄："))
		sex = input('请输入要添加的性别(m,w):')
		classid = input("请输入要添加的班级号：")
		stu=(name,age,sex,classid)
		sql2 = "insert into stu(name,age,sex,classid) values('%s','%d','%s','%s')"%(stu)
		a.Insert(sql2)
		sql1 = 'select * from stu'
		stulist = a.FindAll(sql1)
		for i in stulist:
			print(i)
		input("按回车键继续：")

	elif key == "3":
		print("="*12,"学员信息删除","="*14)
		showStu(stulist)
		sid = int(input("请输入你要删除的信息id号："))
		sql3 = "delete from stu where id='%d'"%(sid)
		a.Del(sql3)
		sql1 = 'select * from stu'
		stulist = a.FindAll(sql1)
		for i in stulist:
			print(i)
		input("按回车键继续：")

	elif key == "4":
		print("="*12,"再见","="*14)
		break
	else:
		print("======== 无效的键盘输入！ ==========")
	